package promote.brozen.algorithm.leetcode._026;

/**
 * @author Brozen
 * @date 2020/9/5 2:49 PM
 * @email brozen@qq.com
 */
public class DeleteRepeatNum {

    public int removeDuplicates(int[] nums) {
        if (nums.length == 0) {
            return 0;
        }

        int fastIdx = 0;
        int slowIdx = 0;
        for (; fastIdx < nums.length; fastIdx++) {
            if (nums[fastIdx] != nums[slowIdx]) {
                slowIdx++;
                nums[slowIdx] = nums[fastIdx];
            }
        }

        return slowIdx + 1;
    }

}
